import archiveIs from './archive-is';
import archiveOrg from './archive-org';
/**
 * Calls all sites specified for archiving
 * @param url Location of page to request Archive.org crawl
 * @param sites String array specifying which sites to archive to
 */
export default function (url, sites) {
  return new Promise(
    (resolve) => {
      let archivePromises = [];
      for (let site of sites) {
        switch (site) {
          case 'archive.org':
            archivePromises.push(archiveOrg(url));
            break;
          case 'archive.is':
            archivePromises.push(archiveIs(url));
            break;
        }
      }
      Promise.all(archivePromises).catch(reason => {
        console.log('Error while archiving:' + reason)
      });

      resolve();
    });
}
